package com.yanqu.road.server.gameplayer.module.activity.fanxiuspring;

import com.yanqu.road.entity.activity.fanxiuspring.FanXiuSpringDrawInfo;
import com.yanqu.road.entity.activity.fanxiuspring.UserFanXiuSpringData;
import com.yanqu.road.pb.activity.FanxiuspringProto;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class FanXiuSpringPb {


    public static List<FanxiuspringProto.FanXiuSpringDrawConfigTemp> buildDrawTemp(List<FanXiuSpringDrawInfo> drawInfoList, String language) {
        List<FanxiuspringProto.FanXiuSpringDrawConfigTemp> list = new ArrayList<>();
        for (FanXiuSpringDrawInfo drawInfo : drawInfoList) {
            FanxiuspringProto.FanXiuSpringDrawConfigTemp.Builder builder = FanxiuspringProto.FanXiuSpringDrawConfigTemp.newBuilder();
            builder.setId(drawInfo.getId());
            builder.setReward(drawInfo.getReward());
            builder.setWeight(drawInfo.getWeight());
            builder.setLv(drawInfo.getLv());
            builder.setIsNotice(drawInfo.getIsNotice());
            list.add(builder.build());
        }
        return list;
    }

    public static FanxiuspringProto.FanXiuSpringUserDataTemp.Builder buildUserData(UserFanXiuSpringData userData) {
        FanxiuspringProto.FanXiuSpringUserDataTemp.Builder builder = FanxiuspringProto.FanXiuSpringUserDataTemp.newBuilder();
        builder.setScore(userData.getScore());
        builder.setLoginDay(userData.getLoginDay());
        builder.setDrawOpp(userData.getDrawOpp());
        builder.addAllPosition(userData.getPositionList());
        builder.setBigReward(userData.getBigReward());
        for (Map.Entry<Integer, Integer> entry : userData.getBigSelectMap().entrySet()) {
            FanxiuspringProto.FanXiuSpringKeyValueTemp.Builder select = FanxiuspringProto.FanXiuSpringKeyValueTemp.newBuilder();
            select.setItemId(entry.getKey());
            select.setNum(entry.getValue());
            builder.addBigSelect(select);
        }
        return builder;
    }
}
